<include file="Core:Public:header" />
{:W('Navigation')}
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">社保套帐</div>
		<div class="row-table-body">
			<p class="form-title">
				<a class="pull-right btn btn-primary btn-xs" href="{:U('hrm/insurance/insurancesuit')}">社保套帐</a>编辑社保套帐
			</p>
			<form class="form-horizontal " action="{:U('hrm/insurance/editinsurancesuit')}" method="post">
				<input type="hidden" name="insurance_suit_id" value="{$info.insurance_suit_id}">
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">名称</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="name" value="{$info.name}" >
					</div>
				</div>
				<div class="form-group">
					<label for="insurance_type" class="col-sm-2 control-label">套帐项目</label>
					<div class="col-sm-8" id="itembox">
						<table class="table table-bordered">
							<tr>
								<td>项目</td>
								<td>缴费基数</td>
								<td>单位缴费</td>
								<td>个人缴费</td>
								<td width="1%"><input type="button" id="additem" class="btn btn-primary btn-xs" value="+" /></td>
							</tr>
							<volist name="info.items" id="v" key="k">
							<tr>
								<td>
									<select name="item[{$k}]">
										<volist name="insuranceitem" id="vo">
										<option value="{$vo.insurance_item_id}" <if condition="$v['item'] == $vo['insurance_item_id']">selected="selected"</if>>{$vo.name}</option>
										</volist>
									</select>
								</td>
								<td>
									<input size="5" type="text" name="base[{$k}]" value="{$v.base}"/>
								</td>
								<td>
									<input size="5" type="text" name="paybycom[{$k}]" value="{$v.paybycom}" />
									<select name="paybycomtype[{$k}]">
										<option value="1" <if condition="$v['paybycomtype'] == 1">selected="selected"</if>>百分比</option>
										<option value="2" <if condition="$v['paybycomtype'] == 2">selected="selected"</if>>定额</option>
									</select>
								</td>
								<td>
									<input size="5" type="text" name="paybyper[{$k}]" value="{$v.paybyper}" />
									<select name="paybypertype[{$k}]">
										<option value="1" <if condition="$v['paybypertype'] == 1">selected="selected"</if>>百分比</option>
										<option value="2" <if condition="$v['paybypertype'] == 2">selected="selected"</if>>定额</option>
									</select>
								</td>
								<td width="1%">
									<input type="button" class="btn btn-primary btn-xs deleteitem" value="-" />
								</td>
							</tr>
							</volist>
						</table>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-3">
						<input name="submit" class="btn btn-primary" type="submit" value="保存"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" value="取消" onclick="javascript:history.go(-1);"/>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
	$(function(){
		var num = {:count($info['items'])} +1 ;
		$('#additem').click(function(){
			var str = '<tr><td><select name="item['+num+']">';
			<volist name="insuranceitem" id="vo">
			str +='<option value="{$vo.insurance_item_id}">{$vo.name}</option>';
			</volist>
			str += '</select></td><td><input size="5" type="text" name="base['+num+']"/></td><td><input size="5" type="text" name="paybycom['+num+']" /><select name="paybycomtype['+num+']"><option value="1">百分比</option><option value="2">定额</option></select></td><td><input size="5" type="text" name="paybyper['+num+']" /><select name="paybypertype['+num+']"><option value="1">百分比</option><option value="2">定额</option></select></td><td width="1%"><input type="button" class="btn btn-primary btn-xs deleteitem" value="-" /></td></tr>';
			$(this).parent().parent().parent().append(str);
			num++;
		});
		$('#itembox').on('click','.deleteitem',function(){
			$(this).parent().parent().remove();
		});
	});
</script>
<include file="Core:Public:alert" />
<include file="Core:Public:footer" />